package meterMonitor.util;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class EncryptPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {

    private String[] encryptPropNames = {"jdbc.username", "jdbc.password"};


    @Override
    protected String convertProperty(String propertyName, String propertyValue) {
        if (isEncryptProp(propertyName)) {
            String decryptValue = DESUtils.decrypt(propertyValue);
            return decryptValue;
        }
        return propertyValue;
    }

    private boolean isEncryptProp(String propertyName) {
        // for (String encryptName : encryptPropNames) {
        //     if (encryptName.equals(propertyName)) {
        //         return true;
        //     }
        // }
        return false;
    }
}
